package biz

import (
	"context"
	"fmt"
	"strings"
)

// 发送markdown格式的钉钉消息
func (uc *GreeterUsecase) sendMarkdownDingTalkMsg(ctx context.Context, title, text string) error {

	builder := strings.Builder{}

	// 标题默认的格式化格式
	builder.WriteString(fmt.Sprintf("### %v \n\n", title))

	builder.WriteString(text)

	errSend := uc.dingOriginApiRobot.SendMarkdownMessage(ctx, title, builder.String())
	if errSend != nil {
		uc.log.WithContext(ctx).Errorf("发送钉钉消息失败: %v", errSend)
	}

	return errSend
}
